/**
 * 字符串转换为小写驼峰
 * @param str
 */
export const toLowerCamelCase = (str: string): string => {
  return str
    .replace(/[-_\s]+(.)?/g, (_, c) => (c ? c.toUpperCase() : ""))
    .replace(/^[A-Z]/, (c) => c.toLowerCase());
};

/**
 * 字符串转换为大写驼峰
 * @param str
 */
export const toUpperCamelCase = (str: string): string => {
  return str
    .replace(/[-_\s]+(.)?/g, (_, c) => (c ? c.toUpperCase() : ""))
    .replace(/^[a-z]/, (c) => c.toUpperCase());
};

/**
 * 字符串转帕金斯命名格式
 * @param str
 */
export const toPascalCase = (str: string): string => {
  return str
    .replace(/[-_\s]+(.)?/g, (_, c) => (c ? c.toUpperCase() : ""))
    .replace(/^[a-z]/, (c) => c.toUpperCase());
};

export const toLowerPascalCase = (str: string): string =>
  toPascalCase(str).toLowerCase();

export const toUpperPascalCase = (str: string): string =>
  toPascalCase(str).toUpperCase();

/**
 * 字符串转连接符命名格式
 * @param str
 */
export const toKebabCase = (str: string): string => {
  return str.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`).replace(/^-/, "");
};

export const toLowerKebabCase = (str: string): string =>
  toKebabCase(str).toLowerCase();

export const toUpperKebabCase = (str: string): string =>
  toKebabCase(str).toUpperCase();
